﻿namespace Zinnia.Lite.Core.Imp
{
    /// <summary>
    /// IO锁服务
    /// </summary>
    internal class IoLockService : IIoLockService
    {
        private readonly System.Threading.ReaderWriterLockSlim _mLock;
        public IoLockService()
        {
            _mLock = new System.Threading.ReaderWriterLockSlim();
        }
        public bool TryEnterReadLock()
        {
            return _mLock.TryEnterReadLock(-1);
        }
        public void ExitReadLock()
        {
            _mLock.ExitReadLock();
        }
        public bool TryEnterWriteLock()
        {
            return _mLock.TryEnterWriteLock(-1);
        }
        public void ExitWriteLock()
        {
            _mLock.ExitWriteLock();
        }
    }
}